package com.caption.mq.listener;


import com.caption.mq.config.MqConsumerAutoConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author ljs
 * @date 2021/10/26
 */
@Component
@Slf4j
public class MqApplicationStartListener implements ApplicationListener<ApplicationReadyEvent> {
    @Autowired
    private MqConsumerAutoConfiguration mqConsumerAutoConfiguration;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event)  {
        log.info("========{}========", "程序启动，开始初始化mq接收端");
        try {
            mqConsumerAutoConfiguration.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
